<template>
    <section>
            <sy-baselist
                    v-show="vMaster"
                    editVue="./report/Trace_Edit.vue"
                    :filters="filters"
                    :fixWhere="'FType='+type"
                    @beforeAdd="beforeAdd"
                    listUrl="server/report/ReportTrace.ashx?cmd=GetList"
                    deleteUrl="server/report/ReportTrace.ashx?cmd=Delete"
            >
                <el-table-column prop="FTitle"  header-align="center" label="主题"  width="150" >
                </el-table-column>
                <el-table-column prop="CustomerName"  header-align="center" label="客户名称"  width="300" >
                    <template scope="scope">
                        <a href="javascript:;" @click="viewCustomer(scope.row)">{{ scope.row.CustomerName }}</a>
                    </template>
                </el-table-column>
                <el-table-column prop="ProjectName"  header-align="center" label="项目名称"  width="200" >
                </el-table-column>
                <el-table-column v-if="type==3" prop="FContractNo"  header-align="center" label="合同编号"  width="200" >
                </el-table-column>
                <el-table-column prop="FCreateDate"  header-align="center" label="日期" :formatter="formatDate" width="130">
                </el-table-column>
                <el-table-column prop="FRealName" header-align="center" label="业务员"  width="160" >
                </el-table-column>
                <el-table-column prop="FNote" header-align="center" label="备注"  width="160" >
                </el-table-column>
            </sy-baselist>

        <div v-show="vCustomer">
            <el-button type="success" size="small" icon="caret-left"
                       style="margin: 10px 0 0 10px" @click="back()">返回</el-button>
            <CustomerOne ref="customerOne"></CustomerOne>
        </div>
    </section>
</template>

<script>
    import util from '../../common/util'
    import mixin from '../../common/mixin'
    import CustomerOne from "../customer/Customer_One.vue"
    export default {
        mixins: [mixin],
        components:{
            CustomerOne:CustomerOne
        },
        watch: {
            '$route' (to, from) {
                // 对路由变化作出响应...
                this.type = this.$router.currentRoute.query.type
            }
        },
        data(){
            return {
                vMaster:true,
                vCustomer:false,
                type:this.$router.currentRoute.query.type,
                filters: [{type: "string",name:"Customer.FName",text:"客户名称"},
                          {type: "date",name:"FCreateDate",text:"日期", value: null},
                          {type: "select",name:"FUserID",text:"业务员", data:"server/system/User.ashx?cmd=GetRealNames"}
                ]
            }
        },
        methods:{
            beforeAdd(row,r){
                let titles = {
                    1:"新增意向客户",
                    2:"新增已发合同客户",
                    3:"新增已签合同客户"
                }
                row.FType = this.type
                row.FTitle = titles[this.type]
            },
            viewCustomer(row){
                //this.$router.push({path: '/Customer',query: {custID: row.FCustID }});
                this.vMaster = false
                this.vCustomer = true
                this.$refs.customerOne._initByID(row.FCustID)
            },
            back(){
                this.vMaster = true
                this.vCustomer = false
            }
        }
    }
</script>
